#ifndef PLAYLISTSERVER_CPP
#define PLAYLISTSERVER_CPP

//size of a message packet
#define MESSAGE_SIZE 128
//size of packet when we are receiving data from a file
#define DATA_SIZE 1024

#define PORT 4998

#include "../Common/playlist.h"
#include "../Common/socket.h"
#include <vector>
#include <iostream>
#include <fstream>
#include <string>

//see cpp for function comments.
class PlaylistServer
{
	public:
		PlaylistServer();
		void runServer();
		inline Playlist* getPlaylist() { return &playlist_; }
	
	private:
		void acceptThread();
		void receiveThread(Socket clientSocket);
		static void threadStart(void* param);
		void removeSocket(Socket s);
		void sendPlaylistToAll();
		void sendPlaylistToClient(Socket clientSock);
		void handleVote(std::string filename);
		void receiveFile(std::string filename, Socket clientSocket, OVERLAPPED* overlapped);

		//current playlist
		Playlist playlist_;
		//current connected clients
		std::vector<Socket> connections_;
};

#endif